package cn.xiaou.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Set;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicComboBoxUI;

import cn.xiaou.domain.User;
import cn.xiaou.draw.MyJButtom;
import cn.xiaou.draw.MyScrollBarUI2;
import cn.xiaou.draw.MyTextFieldBorder;
import cn.xiaou.service.UserService;
import cn.xiaou.service.impl.UserServiceImpl;
import cn.xiaou.utils.ImageManagerUtils;
import cn.xiaou.utils.SendMail;
import cn.xiaou.utils.SmallToolBoxUtils;

/*
 * 功能：用户注册，并合理性判断内置邮件激活账户
 * 创建日期:2018-06-16 04:12:16
 * 最后修改时间：2018-06-17 18:42:56
 * 		--增加合理性判断
 * 		--去除中文增加到数据库
 * 		--完善邮件发送
 * 
 */
public class RegisterView extends JFrame {
	private static final long serialVersionUID = 1L;
	private Set<String >hobbyList = new HashSet<>();
	private static final Font font1 = new Font("黑体", Font.ROMAN_BASELINE, 18);
	private UserService userService = new UserServiceImpl();
	public RegisterView() {
		setIconImage(getToolkit().getImage(ImageManagerUtils.icoUrl));
		//JButton submit = new JButton("提交");
		//JButton back = new JButton("返回");
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				new LoginView();
				setVisible(false);
			 }
		});
		//----------------------------------------
		ImageIcon background = new ImageIcon(ImageManagerUtils.reBG);
		 JLabel bg = new JLabel(background);
		 bg.setBounds(0, 0, background.getIconWidth(),background.getIconHeight());
		 JPanel panel = (JPanel) getContentPane();  
		 //设置透明
		 panel.setOpaque(false);
		 //将背景图的label置于窗体的底层
		 getLayeredPane().add(bg, new Integer(Integer.MIN_VALUE));  
		 panel.setLayout(null);
		//----------------------------------------
		setTitle("用户注册");
		this.setSize(525,700);
		setLocationRelativeTo(null);
		setResizable(false);
		//边框
//		JPanel panel = new JPanel();
//		Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
//		TitledBorder tBorder = BorderFactory.createTitledBorder(border, "注册面板",
//				TitledBorder.CENTER, TitledBorder.TOP);
//		panel.setBorder(tBorder);
//		setContentPane(panel);
//		setLayout(null);
		
		setUndecorated(true);
	    setBackground(new Color(0,0,0,0));
		
		
		//提示框
		JLabel [] promptLabel = new JLabel[8];
		JPanel promptGroup = new JPanel();
		panel.add(promptGroup);
		promptGroup.setBounds(360, 45, 125, 300);
		promptGroup.setLayout(null);
		promptGroup.setOpaque(false);
		
		for(int i=0;i<=7;i++) {
			promptLabel[i]=new JLabel();
			promptLabel[i].setForeground(Color.RED);
			promptLabel[i].setBounds(0,0+35*i , 125, 30);
			
			promptGroup.add(promptLabel[i]);
			
		}
		promptLabel[5].setBounds(0,5+35*5 , 125, 30);
		promptLabel[6].setBounds(0,2+35*6 , 125, 30);
		/*promptLabel[7].setBounds(0, 2+35*7, 120, 30);*/
		
		JLabel nameLabel = new JLabel("用户名：");
		nameLabel.setForeground(Color.WHITE);
		nameLabel.setBounds(100, 50, 100, 25);
		panel.add(nameLabel);
		nameLabel.setFont(font1);
		JTextField username = new JTextField();
		username.addFocusListener(new ShineJText(Color.WHITE, Color.BLACK));
		username.setOpaque(false);
		username.setBorder(new MyTextFieldBorder(Color.BLACK));
		username.setForeground(Color.WHITE);
		panel.add(username);
		username.setBounds(185, 50, 150, 25);
		username.addFocusListener(new FocusListener() {
			@Override
			public void focusLost(FocusEvent arg0) {
				promptLabel[0].setForeground(Color.RED);
				if(!checkNoEmptyText(username)) {
					promptLabel[0].setText("用户名不能为空");
					return;
				}
				if(username.getText().length()>12) {
					promptLabel[0].setText("不能多于12个字符");
					return;
				}
				if(!username.getText().matches("[a-zA-Z0-9]+")) {
					promptLabel[0].setText("存在非法字符");
					return;
				}
				
				if(!userService.isExistUserByUsername(username.getText())) {
					promptLabel[0].setText("用户名已经存在");
					return;
				}
				promptLabel[0].setText("");
			}
			@Override
			public void focusGained(FocusEvent arg0) {
				promptLabel[0].setForeground(Color.GREEN);
				if(!checkNoEmptyText(username)) {
					promptLabel[0].setText("只能是数字或者字符");
				}
				
			}
		});
		
		JLabel passwordLabel = new JLabel("密  码：");
		passwordLabel.setForeground(Color.WHITE);
		passwordLabel.setBounds(100, 85, 100, 25);
		panel.add(passwordLabel);
		passwordLabel.setFont(font1);
		JPasswordField password = new JPasswordField();
		password.addFocusListener(new ShineJText(Color.WHITE));
		password.setOpaque(false);
		password.setBorder(new MyTextFieldBorder(Color.BLACK));
		password.setForeground(Color.WHITE);
		panel.add(password);
		password.setBounds(185, 85, 150, 25);
		password.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent e) {
				promptLabel[1].setForeground(Color.RED);
				if(!checkNoEmptyText(password)) {
					promptLabel[1].setText("密码不能为空");
					return;
				}
				if(new String(password.getPassword()).length()<6) {
					promptLabel[1].setText("密码少于6位");
					return;
				}
				if(new String(password.getPassword()).length()>12) {
					promptLabel[1].setText("密码不能多于6位");
					return;
				}
				promptLabel[1].setText("");
			}
			
			@Override
			public void focusGained(FocusEvent arg0) {
				promptLabel[1].setForeground(Color.GREEN);
				if(!checkNoEmptyText(password)) {
					promptLabel[1].setText("密码至少6位");
				}
			}
		});
		
		JLabel passwordReLabel = new JLabel("重复密码：");
		passwordReLabel.setForeground(Color.WHITE);
		passwordReLabel.setBounds(85, 120, 100, 25);
		panel.add(passwordReLabel);
		passwordReLabel.setFont(font1);
		JPasswordField passwordRe = new JPasswordField();
		passwordRe.setOpaque(false);
		passwordRe.addFocusListener(new ShineJText(Color.WHITE, Color.BLACK));
		passwordRe.setBorder(new MyTextFieldBorder(Color.BLACK));
		passwordRe.setForeground(Color.WHITE);
		panel.add(passwordRe);
		passwordRe.setBounds(185, 120, 150, 25);
		passwordRe.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent e) {
				promptLabel[2].setForeground(Color.RED);
				if(!checkNoEmptyText(passwordRe)) {
					promptLabel[2].setText("重复密码不能为空");
					return;
				}
				if(!new String(password.getPassword()).equals(new String(passwordRe.getPassword()))) {
					promptLabel[2].setText("输入密码不一致");
					return;
				}
				promptLabel[2].setText("");
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				promptLabel[2].setForeground(Color.GREEN);
				if(!checkNoEmptyText(passwordRe)) {
					promptLabel[2].setText("请再输入一次密码");
				}
			}
		});
		/*//出生日期
		JLabel birthday = new JLabel("出生日期：");
		add(birthday);
		birthday.setBounds(85, 155, 177, 24);
		birthday.setFont(font1);
		final JXDatePicker birthdayDate = new JXDatePicker();
		add(birthdayDate);
		birthdayDate.setDate(new Date());
		birthdayDate.setBounds(185, 155, 177, 24);*/
		//学历
		JLabel educationLabel = new JLabel("学  历：");
		panel.add(educationLabel);
		educationLabel.setBounds(100, 155, 150, 24);
		educationLabel.setFont(font1);
		educationLabel.setForeground(Color.WHITE);
		UIManager.put("ComboBox.background", new Color(0,0,0,0));
		JComboBox<String >education = new JComboBox<>();
		education.setOpaque(false);
		education.setUI(new BasicComboBoxUI() {
			public void installUI(JComponent comboBox) {
                super.installUI(comboBox);
                listBox.setForeground(Color.WHITE);
                listBox.setSelectionBackground(new Color(0,0,0,0));
                listBox.setSelectionForeground(Color.YELLOW);
            }
			 protected JButton createArrowButton() {
				 	JButton up = new MyJButtom(ImageManagerUtils.rdown);
	                return up;
	         }
             
		});
		education.setBorder(new MyTextFieldBorder(Color.BLACK));
		education.setForeground(Color.WHITE);
		education.addItem("请选择");
		education.addItem("高中");
		education.addItem("大专");
		education.addItem("本科");
		education.addItem("硕士");
		education.setOpaque(false);
		panel.add(education);
		education.setBounds(185, 155, 150, 24);
		education.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent e) {
				if(!"请选择".equals(education.getSelectedItem().toString())) {
					promptLabel[3].setText("");
				}
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				if(!"请选择".equals(education.getSelectedItem().toString())) {
					promptLabel[3].setText("");
				}
				
			}
		});
		//性别
		JLabel genderLabel = new JLabel("性  别：");
		genderLabel.setForeground(Color.WHITE);
		genderLabel.setBounds(100, 190, 100, 25);
		panel.add(genderLabel);
		genderLabel.setFont(font1);
		ButtonGroup gender = new ButtonGroup();
		JRadioButton female = new JRadioButton("女");
		female.setForeground(Color.WHITE);
		female.setOpaque(false);
		JRadioButton male = new JRadioButton("男");
		male.setForeground(Color.WHITE);
		male.setOpaque(false);
		female.setSelected(true);
		female.setBounds(180, 180, 50, 50);
		male.setBounds(230, 180, 50, 50);
		gender.add(male);
		gender.add(female);
		panel.add(female);
		panel.add(male);
		//电子邮箱
		JLabel emailLabel = new JLabel("电子邮箱：");
		emailLabel.setForeground(Color.WHITE);
		emailLabel.setBounds(85, 230, 100, 25);
		panel.add(emailLabel);
		emailLabel.setFont(font1);
		JTextField email = new JTextField();
		email.addFocusListener(new ShineJText(Color.WHITE, Color.BLACK));
		email.setOpaque(false);
		email.setBorder(new MyTextFieldBorder(Color.BLACK));
		email.setForeground(Color.WHITE);
		panel.add(email);
		email.setBounds(185, 230, 150, 25);
		setVisible(true);
		email.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent e) {
				promptLabel[5].setForeground(Color.RED);
				if(!checkNoEmptyText(email)) {
					promptLabel[5].setText("电子邮箱不能为空");
					return;
				}
				if(!email.getText().matches("^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w+)+)$")) {
					promptLabel[5].setText("电子邮箱非法");
					return;
				}
				if(!userService.checkExistEmail(email.getText())) {
					promptLabel[5].setText("电子邮箱已经存在");
					return;
				}
				promptLabel[5].setText("");
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				promptLabel[5].setForeground(Color.GREEN);
				if(!checkNoEmptyText(email)) {
					promptLabel[5].setText("请输入电子邮箱");
				}
			}
		});
		
		
		//爱好
		JLabel hobbyLabel = new JLabel("爱  好：");
		hobbyLabel.setForeground(Color.WHITE);
		hobbyLabel.setBounds(100, 260, 100, 22);
		panel.add(hobbyLabel);
		hobbyLabel.setFont(font1);
		JPanel hobbyJpenl = new JPanel();
		hobbyJpenl.setBounds(170, 255, 300, 20);
		hobbyJpenl.setSize(new Dimension(200, 45));
		JCheckBox hobbyCheck1 = new JCheckBox("看书");
		hobbyCheck1.setForeground(Color.WHITE);
		hobbyCheck1.setOpaque(false);
		JCheckBox hobbyCheck2 = new JCheckBox("睡觉");
		hobbyCheck2.setForeground(Color.WHITE);
		hobbyCheck2.setOpaque(false);
		JCheckBox hobbyCheck3 = new JCheckBox("跑步");
		hobbyCheck3.setForeground(Color.WHITE);
		hobbyCheck3.setOpaque(false);
		hobbyJpenl.add(hobbyCheck1);
		hobbyJpenl.add(hobbyCheck2);
		hobbyJpenl.add(hobbyCheck3);
		hobbyJpenl.setOpaque(false);
		panel.add(hobbyJpenl);
		
		hobbyCheck1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if(hobbyCheck1.isSelected()) {
					promptLabel[6].setText("");
					hobbyList.add(hobbyCheck1.getText());
				}else {
					hobbyList.remove(hobbyCheck1.getText());
				}
			}
		});
		hobbyCheck2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if(hobbyCheck2.isSelected()) {
					hobbyList.add(hobbyCheck2.getText());
				}else {
					hobbyList.remove(hobbyCheck2.getText());
				}
			}
		});
		hobbyCheck3.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if(hobbyCheck3.isSelected()) {
					hobbyList.add(hobbyCheck3.getText());
				}else {
					hobbyList.remove(hobbyCheck3.getText());
				}
			}
		});
		//出生日期
		
		JLabel birthdayLabel = new JLabel("出生日期：");
		birthdayLabel.setForeground(Color.WHITE);
		birthdayLabel.setFont(font1);
		panel.add(birthdayLabel);
		birthdayLabel.setBounds(90, 294, 100, 25);
		JTextField birthday = new JTextField();
		birthday.addFocusListener(new ShineJText(Color.WHITE, Color.BLACK));
		birthday.setOpaque(false);
		birthday.setBorder(new MyTextFieldBorder(Color.BLACK));
		birthday.setForeground(Color.WHITE);
		birthday.setBounds(185, 294, 150, 25);
		birthday.setForeground(Color.white);
		birthday.setText("例子:1970-03-03");
		panel.add(birthday);
		birthday.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent arg0) {
				if(birthday.getText().equals("")) {
					birthday.setForeground(Color.WHITE);
					birthday.setText("例子:1970-03-03");
					promptLabel[7].setText("出生日期为空");
				}
				if(!birthday.getText().matches("(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)")) {
					birthday.setForeground(Color.WHITE);
					birthday.setText("例子:1970-03-03");
					promptLabel[7].setText("出生日期格式有误");
				}else {
					promptLabel[7].setText("");
				}
				
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				((JTextField) e.getSource()).setText("");
				((JTextField) e.getSource()).setForeground(Color.WHITE);
			}
		});
		birthday.addKeyListener(new KeyListener() {
			private Integer state=0;
			@Override
			public void keyTyped(KeyEvent e) {
				if(!(e.getKeyChar()>='0'&&e.getKeyCode()<='9'||e.getID()==400)) {
					if(birthday.getText().length()!=0) {
						birthday.setText(birthday.getText().substring(0, birthday.getText().length()-1));
					}
				}
				
				if((birthday.getText().length()==4||birthday.getText().length()==7) && state!=8) {
					birthday.setText(birthday.getText()+"-");
				}
				
				
			}
			
			@Override
			public void keyReleased(KeyEvent e) {
				
			}
			
			@Override
			public void keyPressed(KeyEvent e) {
				state =e.getKeyCode();
			}
		});
		birthday.addFocusListener(new FocusListener() {
			
			@Override
			public void focusLost(FocusEvent e) {
				if(birthday.getText().equals("")) {
					promptLabel[7].setText("出生日期为空");
					return;
				}
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				
			}
		});
		//简介
		JLabel synopsisLabel = new JLabel("个人简介");
		synopsisLabel.setForeground(Color.WHITE);
		synopsisLabel.setBounds(185, 340, 100, 25);
		synopsisLabel.setFont(new Font("黑体", Font.ROMAN_BASELINE, 25));
		panel.add(synopsisLabel);
		JTextArea synopsisTextArea= new JTextArea();
//		synopsisTextArea.addFocusListener(new ShineJText(Color.WHITE, Color.BLACK));
		synopsisTextArea.setOpaque(false);
		synopsisTextArea.setBorder(new MyTextFieldBorder(Color.BLACK));
		/*synopsisTextArea.setForeground(Color.WHITE);*/
        JScrollPane synopsisTextAreaScroll = new JScrollPane(synopsisTextArea);
//        synopsisTextAreaScroll.setOpaque(false);
        synopsisTextAreaScroll.setBounds(50, 380, 400, 200);
       /* synopsisTextAreaScroll.setVerticalScrollBarPolicy();*/
        synopsisTextAreaScroll.getVerticalScrollBar().setUI(new MyScrollBarUI2());
        synopsisTextAreaScroll.setOpaque(false);
        synopsisTextAreaScroll.getViewport().setOpaque(false);
        synopsisTextAreaScroll.setBorder(null);
        panel.add(synopsisTextAreaScroll);
        synopsisTextArea.setForeground(new Color(192,192,192));
		synopsisTextArea.setText("请输入个人简介，最多255个字符");
        synopsisTextArea.addFocusListener(new FocusListener() {
			@Override
			public void focusLost(FocusEvent e) {
				if(synopsisTextArea.getText().equals("")) {
					synopsisTextArea.setForeground(new Color(192,192,192));
					synopsisTextArea.setText("请输入个人简介，最多255个字符");
					return;
				}
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				if("请输入个人简介，最多255个字符".equals(synopsisTextArea.getText())) {
					synopsisTextArea.setText("");
					synopsisTextArea.setForeground(Color.white);
				}
			}
		});
        
        //提交
        JButton submit = new MyJButtom(ImageManagerUtils.submitBg);
        panel.add(submit);
		submit.setBounds(115, 600, 75, 35);
		submit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				User user = new User();
				Boolean f= true;
				int []a = {0,1,2,5,7};
				for(int i :a ) {
					if(!"".equals(promptLabel[i].getText())) {
						f=false;
					}
				}
				if(f) {
					user.setUsername(username.getText());
					user.setPassword(new String(password.getPassword()));
					user.setEmail(email.getText());
					user.setBirthday(birthday.getText());
					if(!"请选择".equals(education.getSelectedItem().toString())) {
						try {
							user.setEducation(URLEncoder.encode(education.getSelectedItem().toString(), "utf-8"));
						} catch (UnsupportedEncodingException e3) {
							e3.printStackTrace();
							JOptionPane.showMessageDialog(null, "未知错误33055");
							System.exit(0);
						}
						if(!hobbyList.isEmpty()) {
							String str = null;
							for(String hobby: hobbyList) {
								if(str==null) 
									str=hobby;
								else 
									str+=hobby+"|";
							}
							try {
								user.setHobby(URLEncoder.encode(str, "utf-8"));
							} catch (UnsupportedEncodingException e2) {
								e2.printStackTrace();
								JOptionPane.showMessageDialog(null, "未知错误33055");
								System.exit(0);
							}
							if(synopsisTextArea.getText().length()!=0 ||synopsisTextArea.getText().length()>255) {
								if(male.isSelected()) {
									user.setGender("1");
								}else if(female.isSelected()) {
									user.setGender("0");
								}
								try {
									user.setSynopsis(URLEncoder.encode(synopsisTextArea.getText(), "utf-8"));
									
								} catch (UnsupportedEncodingException e1) {
									e1.printStackTrace();
									JOptionPane.showMessageDialog(null, "未知错误33055");
									System.exit(0);
								}
								//发送激活邮件
								 String code = SmallToolBoxUtils.getRandomInt(6);
								 user.setEmail_state(code);
								 String msg="  你好欢迎使用\n"+"你的激活码是"+code;
								Thread sendMail = new Thread(new SendMail(user.getEmail(), msg,"用户注册"));
								sendMail.start();
								user.setMoney(0.0);
								Boolean state= userService.registerUser(user);
								if(state) {
									JOptionPane.showConfirmDialog(null, "注册成功", "提示窗口",JOptionPane.WARNING_MESSAGE);
									new LoginView();
									dispose();
								}
							}else {
								//JOptionPane.showConfirmDialog(null, "个人简介未输入或输入字符大于255个", "提示",JOptionPane.ERROR_MESSAGE);
								Object[] options = { "返回"}; 
								JOptionPane.showOptionDialog(null, "个人简介未输入或输入字符大于255个", "警告", 
										JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, 
										null, options,options[0]); 
							}
						}else {
							promptLabel[6].setText("爱好未选择");
						}
						
					}else {
						promptLabel[3].setText("学历未选择");
					}
					
				}else {
					//JOptionPane.showConfirmDialog(null, "信息未填完整", "提示窗口",JOptionPane.WARNING_MESSAGE);
					Object[] options = { "返回"}; 
					JOptionPane.showOptionDialog(null, "信息未填完整", "警告", 
							JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, 
							null, options,options[0]); 
				}
				
				
				
				
				/*if(RegisterView.checkTest(username, 0)) {
					user.setUsername(username.getText());
					if(RegisterView.checkTest(password, 0)) {
						user.setPassword(new String(password.getPassword()));
						if(RegisterView.checkTest(email, 0)) {
							user.setEmail(email.getText());
							if(!"请选择".equals(education.getSelectedItem().toString())) {
								user.setEducation(education.getSelectedItem().toString());
								if(!hobbyList.isEmpty()) {
									for(String hobby: hobbyList) {
										user.setHobby(hobby+"|");
									}
									if(synopsisTextArea.getText().length()!=0) {
										if(male.isSelected()) {
											user.setGender("1");
										}else if(female.isSelected()) {
											user.setGender("0");
										}
										if(user.getGender()!=null) {
											user.setSynopsis(synopsisTextArea.getText());
											user.setEmail_state(0);
											Boolean state= userService.registerUser(user);
											if(state) {
												JOptionPane.showConfirmDialog(null, "注册成功", "提示窗口",JOptionPane.WARNING_MESSAGE);
												new EntranceView();
												setVisible(false);
											}
										}
										
									}
								}
							}
						}
						
						
					}
					
					
				}	*/			
			}
		});
		
        //重置
        JButton reset = new MyJButtom(ImageManagerUtils.resetBg);
		add(reset);
		reset.setBounds(300, 600, 75, 35);
		reset.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				username.setText("");
				password.setText("");
				passwordRe.setText("");
				female.isSelected();
				hobbyCheck1.setSelected(false);
				hobbyCheck2.setSelected(false);
				hobbyCheck3.setSelected(false);
				synopsisTextArea.setText("");
				email.setText("");
				hobbyList.clear();
				education.setSelectedIndex(0);
			}
		});
        //返回
        JButton back = new MyJButtom(ImageManagerUtils.backBg);
		add(back);
		back.setBounds(400, 645, 100, 25);
		back.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				new LoginView();
				dispose();
			}
		});
	}
	//判断文本是否为空
	private static Boolean checkNoEmptyText(JTextField text) {
		if(text.getText().length()>0) {
			return true;
		}else {
			return false;
		}
	}
	
	/*private  static void sendMail(String msg,String email) throws Exception  {
		MailUtils mail = new MailUtils(false);
		mail.initMessage();
		mail.setRecipient(email);
		//设置邮箱名称
		mail.setFrom("....");
		mail.setText("  你好欢迎使用\n"+"你的激活码是"+msg);
		mail.setSubject("注册激活账号");
		mail.sendMessage();
	}*/
	/*private static Boolean checkTest(JTextField text,Integer min) {
		if(min!=0) {
			if(text.getText().length()>=min) {
				return true;
			}else {
				return false;
			}
		}
		if(text.getText().length()>0) {
			return true;
		}else {
			return false;
		}
		
	}*/
}

